package com.jic.order;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import com.jic.common.swagger.config.Swagger2Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

@EnableSwagger2
@EnableSwaggerBootstrapUI
@EnableFeignClients(basePackages = {"com.jic.conf.api","com.jic.member.api","com.jic.product.after.api","com.jic.market.api","com.jic.product.store","com.jic.manager.api","com.jic.order.api"})
@EnableTransactionManagement
@EnableDiscoveryClient
@EnableAsync
@EnableScheduling
@SpringBootApplication(scanBasePackages = {"com.jic.order","com.github.wxpay"})
public class JicOrderImplApplication {

    public static void main(String[] args) {
        SpringApplication.run(JicOrderImplApplication.class, args);
    }

    @Bean
    @ConditionalOnMissingBean
    public Docket getDocket(){
        return new Swagger2Config().createRestApi(this.getClass().getSimpleName());
    }


    /**
     * 时区设置
     */
    @PostConstruct
    void started() {
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
    }
}
